<template>
  <el-dialog :title="stuTitle" :visible.sync="visible" :fullscreen="true" :close-on-click-modal="false"
    :close-on-press-escape="false" append-to-body>
    <div>
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
        <el-form-item label="姓名" prop="stuName">
          <el-input v-model="queryParams.stuName" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="昵称" prop="nickName">
          <el-input v-model="queryParams.nickName" placeholder="请输入昵称" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="性别" prop="stuSex">
          <el-select v-model="queryParams.stuSex" placeholder="请选择性别" clearable>
            <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
              :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="学号" prop="stuCode">
          <el-input v-model="queryParams.stuCode" placeholder="请输入学号" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="登录手机号" prop="tel">
          <el-input v-model="queryParams.tel" placeholder="请输入登录手机号" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="studentList">
        <el-table-column label="id" align="center" prop="id" :show-overflow-tooltip="true" />
        <el-table-column label="姓名" align="center" prop="stuName" :show-overflow-tooltip="true" />
        <el-table-column label="昵称" align="center" prop="nickName" :show-overflow-tooltip="true" />
        <el-table-column label="性别" align="center" prop="stuSex" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.stuSex" />
          </template>
        </el-table-column>
        <el-table-column label="会员有效期" align="center" prop="memberType" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.stu_member_type" :value="scope.row.memberType" />
          </template>
        </el-table-column>
        <el-table-column label="年龄" align="center" prop="age" :show-overflow-tooltip="true" />
        <el-table-column label="登录手机号" align="center" prop="tel" :show-overflow-tooltip="true" />
        <el-table-column label="校区" align="center" prop="schoolName" :show-overflow-tooltip="true" />
        <el-table-column label="上线" align="center" prop="state" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.common_state" :value="scope.row.state" />
          </template>
        </el-table-column>
        <el-table-column label="结束日期" align="center" :show-overflow-tooltip="true" prop="validTo">

        </el-table-column>
      </el-table>
      <pagination v-show="stuTotal>0" :total="stuTotal" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getStuList" />

    </div>
  </el-dialog>
</template>

<script>
  import {
    listStudent,
  } from "@/api/bus_web/school/student";

  export default {
    name: "School_student_report",
    dicts: ['sys_user_sex', 'common_state', 'stu_member_type'],
    components: {

    },
    data() {
      return {
        // 遮罩层
        loading: true,
        stuTitle:'',
        // 显示搜索条件
        showSearch: true,
        visible: false,
        // 总条数
        stuTotal: 0,
        studentList: [],
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          schoolIdArray:[]
        }
      };
    },
    methods: {
      init(row) {
        this.stuTitle='['+row.schoolName+']实际招生人数'
        this.resetForm("queryForm")
        this.queryParams.schoolIdArray.push(row.id)
        this.visible = true
        this.getStuList()
      },
      getStuList() {
        this.loading = true;
        listStudent(this.queryParams).then(response => {
          this.studentList = response.rows;
          this.stuTotal = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
    }
  };
</script>
